class calculator{
/*
	// Reverswe string
	
	public static char[] rev(char[] r){
	char[] result=new char[r.length];
	r[last]=r.length-1;
		for(int i=0;i<result.length;i++){
		r[i]=r[last];
		last--;
		
		}
			return result;
		}
	*/	
	//print 
	
	public static void print(int[] r){
		for(int i=0;i<r.length;i++){
		  System.out.println(r[i]);
		}
	}

	// fibonacci
	
	 public static int[] fibo(int f){
	 int []fib=new int[f];
	 fib[0]=0;
	 fib[1]=1;
	 for(int i=2;i<f;i++){
	 fib[i]=fib[i-1]+fib[i-2];
	 }
	 return fib;
	 
	 }
	
	
	// even no

	public static int[] even(int f,int t){
	
	int[] e=new int[t];
	int count=0;
	for(int i=f;i<=t;i++){
	if(i%2==0){
		e[count]= i;
		count++;
	}
	}
	return e;
	}

// odd no

	public static int[] odd(int f,int t){
	
	int[] e=new int[t];
	int count=0;
	for(int i=f;i<=t;i++){
	if(i%2==1){
		e[count]= i;
		count++;
	}
	}
	return e;
	}
	
	// compute the sum of all the elements in an arrays
	
	public static int suma(int[] arr){
	int temp=0;
	int res;
	for(int i=0;i<arr.length;i++){
	res=temp+arr[i];
	temp=res;
	}
	return temp;
	}
	}
		
		/*// Generate random numbers

	public static int[][] GenRanMatrix(int r, int c){
		int[][] mat= new int[r][c];
		for(int i=0;i<mat.length;i++){
		for(int j=0;j<mat[i].length;j++){
			mat[i][j]=(int)(Math.random()*10);
			}
		}
		return mat;
	}

// print  matrix

	public static void PrintMulArr(int[][] arr){

		for(int i=0;i<arr.length;i++){
		for(int j=0;j<arr[i].length;j++){
			System.out.print(arr[i][j]+" ");
			}
		System.out.println();
		}
	}

// addition of two  matrix

	public static void AddMulArr(int[][] arr1, int[][] arr2){
	for(int i=0;i<arr2.length;i++){
		for(int j=0;j<arr2.length;j++){
			System.out.print(arr1[i][j]+arr2[i][j]+" ");
			}
		System.out.println();
		}
	}

// mul of two  matrix

	public static void MulpMulArr(int[][] arr1, int[][] arr2){

	for(int i=0;i<arr2.length;i++){
		for(int j=0;j<arr2.length;j++){
			for(int k=0;k<arr2.length;k++){
				int[][] res=new int [arr2.length][arr2.length];
				res[i][j]+=(arr1[i][k]*arr2[k][j]);
				System.out.print(res[i][j]+" ");
				}
			}
		System.out.println();
		}
	}
	
	// sum of all element in mul dim array

	public static void sumMDA(int[][] arr){
	int temp=0;
	
	for(int i=0;i<arr.length;i++){
		for(int j=0;j<arr.length;j++){
		
		temp+=arr[i][j];
			}
		}
		System.out.println(temp);
	}
	
	// sum of rows and columns  seperatly in mul dim array

	public static void sumRC(int[][] arr){
	int rows=0;
	int columns=0;
	
	for(int i=0;i<arr.length;i++){
		for(int j=0;j<arr.length;j++){
		rows+=arr[i][j];
		}
		System.out.println(rows);
		rows=0;
		}
		
	}
	
public static void main(String[] args)
{
//string to integer conversion
	String emp="a";
	int intvalue=Integer.parseInt(emp);
	System.out.println("string to integer"+intvalue);

	//string to double conversion
	String sal="150000.56";
	double doubleval=Double.parseDouble(sal);
	System.out.println("string to double"+doubleval);
	
	//radius experiments
	int rad=5;
	if(rad>=0){
	double area=rad*rad*3.142;
	System.out.println("the area of the circle is "+area);
	}

	//case for float
	float status=2.345;
	switch(status){
	case 2.135: System.out.println("first float case");
	break;
	case 2.234: System.out.println("second float case");
	break;
	case 2.345: System.out.println("third flaot case");
	break;
	default:System.out.println("invalid choice");
	}

	//exp in switch
	char ch='a';
	switch(ch){
	case 'a':System.out.println(ch);
	case 'b':System.out.println(ch);
	case 'c':System.out.println(ch);
	}

	System.out.println("2013 is leap year:"+leap(2013));
	//even or odd
	System.out.println("11 is "+evn(11));
	System.out.println("10 is "+evn(10));
	//print 10 times
	int i=1;
	while(i<=10){
	System.out.println("I WILL PRACTICE EVERYDAY\n");
	i++;
	}
	
	//prime or not
	for(int i1=13;i<15;i++){
if(isprime(i1))
System.out.println(i1+" is a prime number\n");
else
System.out.println(i1+" is not a prime number\n");
	}
	
	
	//fibonacii series
	System.out.println(fib(10));
	//max of 2 int and double
	System.out.println("larger no among 10 and 20 is :"+max(10,20));
	System.out.println("larger no among 10.254678 and 20.254678 is :"+max(10.25678,20.254678));
	System.out.println(exp());
}
//binary search//
int[] data;
int size;

 public boolean binarySearch(int key) 
 {
int low = 0;
int high = size - 1;
while(high >= low) {
int middle = (low + high) / 2;
if(data[middle] == key) {
return true;
}
if(data[middle] < key) {
low = middle + 1;
}
if(data[middle] > key) {
high = middle - 1;
}        
} 
return false;
}



//linearsearch//
 class LinearSearch {
public static void main(String[] args)
{
System.out.println("Linear Search List");
int[] arr = {0,2879, 15, 29, 78, 26, 24, 44, 167, 13,24,47};
int i;       
int num = 3;
boolean flag=false;
for(i=0; i<arr.length; i++){
if(arr[i]==num){
flag=true;
break;
}
}
//for
if(flag){
System.out.println(num + " index  position "+i);
}
else
{
System.out.println(num + " no not found");
}             
}    
}

//mergesort//	   
 class mergeSort{
  public static void main(String a[]){
  int i;
  int array[] = {78,96,35,9,12,17,3,105};
  System.out.println("Values Before the sort:\n");
  for(i = 0; i < array.length; i++)
  System.out.print( array[i]+"  ");
  System.out.println();
  mergeSort_srt(array,0, array.length-1);
  System.out.print("Values after the sort:\n");
  for(i = 0; i <array.length; i++)
  System.out.print(array[i]+"  ");
 }
  public static void mergeSort_srt(int array[],int lo, int n){
  int low = lo;
  int high = n;
  if (low >= high) {
  return;
  }

  int middle = (low + high) / 2;
  mergeSort_srt(array, low, middle);
  mergeSort_srt(array, middle + 1, high);
  int end_low = middle;
  int start_high = middle + 1;
  while ((lo <= end_low) && (start_high <= high)) {
  if (array[low] < array[start_high]) {
  low++;
  } else {
  int Temp = array[start_high];
  for (int k = start_high- 1; k >= low; k--) {
  array[k+1] = array[k];
  }
  array[low] = Temp;
  low++;
  end_low++;
  start_high++;
  }
  }
  }  
}

//bubble sort//
public static void bubbleSort(int[] matrix)
{	
for(int i = 0; i < matrix.length; i++) 
for(int j = i+1 ; j < matrix.length;j++)
if(matrix[i]>matrix[j])
{
int temp = matrix[i];
matrix[i] = matrix[j];
matrix[j] = temp;
}



//selection sort//
public static void selectionSort(int[] matrix)
{
int pos = -1;		
for(int i = 0; i < matrix.length; i++)
{
pos = i;
for(int j = i+1 ;j < matrix.length; j++)
if(matrix[j]<matrix[pos])
pos = j;				
int temp = matrix[pos];
matrix[pos] = matrix[i];
matrix[i] = temp;
}
}
//leap year//
public static boolean leap(int year){
	if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
return true;
else
return false;
}

//addition//
public static void main( String[] args)
{ double a=10.01,b=20.02;
double r;
r=a+b;
 System.out.println(r);
}
}

//even or odd//
public static void evn(int num){
	System.out.println((num%2==0)? "even number": "odd number");
}
	//maximum(int)//
public static int max(double n1,double n2){
	if(n1>n2)
	return n1;
	else
	return n2;
}
	
	
	}
	
*/